package com.soda.util;

public class PageInfo {

	//分页信息，以下是默认值，给分页对象赋值时，需先给total赋值，setTotal方法随机自动计算出lastpage，因此使用时不需再给lastpage赋值
	//per为每页显示条数，根据需要可传参数进行赋值，默认为3
	private int page=1;
	private int per=3;
	private int lastPage=1;
	private int total=0;
	private String url;
	private String str;
	private int startIndex=0;
	
	public int getStartIndex() {
		return startIndex;
	}

	public void setStartIndex(int startIndex) {
		
	}
	public void setStartIndex() {
		this.startIndex =(page-1)*per;
	}
	public PageInfo() {
		// TODO Auto-generated constructor stub
	}

	public PageInfo(int page, int per, int lastPage, int total) {
		super();
		this.page = page;
		this.per = per;
		this.lastPage = lastPage;
		this.total = total;
	}

	public PageInfo(int page, int per, int lastPage, int total, String url,
			String str) {
		super();
		this.page = page;
		this.per = per;
		this.lastPage = lastPage;
		this.total = total;
		this.url = url;
		this.str = str;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getStr() {
		return str;
	}

	public void setStr(String str) {
		this.str = str;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		if(page<=1)
			this.page=1;
		else if(page>=this.lastPage)
			this.page=this.lastPage;
		else
		    this.page = page;
	}

	public int getPer() {
		return per;
	}

	public void setPer(int per) {
		this.per = per;
	}

	public int getLastPage() {
		return lastPage;
	}

	public void setLastPage(int lastPage) {
		this.lastPage = lastPage;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		
		this.lastPage=(total+per-1)/per;
		this.total = total;
	}
	
}
